Skip to content

Fix integer division in EV3 motor code#6

Open
MaartenS11 wants to merge 2 commits intoOpenBotBrain:mainfrom
MaartenS11:fix/motor-speed-division
Open

Fix integer division in EV3 motor code#6
MaartenS11 wants to merge 2 commits intoOpenBotBrain:mainfrom
MaartenS11:fix/motor-speed-division

Conversation

@MaartenS11
Copy link

There was an integer division in the EV3 large motor code that took the speed and divided by 1000. The speed of the motor is an integer, 1000 is also an integer so it did an integer division. If you set the speed to DEFAULT_MOTOR_SPEED for example this results in the value 0 instead of the expected 0.5.

This integer division made it impossible to make the motor move at speeds below the maximum speed.

The integer division caused any speed lower than 1000 to become 0resulting in a motor that didn't do anything.
Copy link
Contributor

@sggtav sggtav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a good practice to add the “f” at the end of the float values, like 123.4f. But it is fine as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants